<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    let arr = [1, 2, 3, 4, 5, 6];
    let index = arr.findIndex((v, i) => {
      if (v === 5) {
        return true;
      }
    });
    console.log(index);
    let arrObj = [
      {
        goods_id: 1,
        name: "产品1",
      },
      {
        goods_id: 2,
        name: "产品1",
      },
      {
        goods_id: 3,
        name: "产品1",
      },
    ];
    //   let index2 =   arrObj.findIndex(v=>{
    //         if(v.goods_id === 2){
    //             return true;
    //         }
    //     })
    let index2 = arrObj.findIndex((v) => {
      if (v.goods_id === 5) {
        return true;
      }
    });
    console.log(index2);
  </script>
</html>
